
#pragma once

#include <windef.h>

#include <d3d11.h>

#include "Core\Bindable.h"
#include "Tools\Size.h"

#pragma comment(lib, "d3d11.lib")

class Vector4;

class RenderTarget : public Bindable
{
public:
	RenderTarget(CONST Size& size,
				 DXGI_FORMAT format = DXGI_FORMAT_R32G32B32A32_FLOAT,
				 UINT flags = 0,
		         UINT max_mip_level = 0,
				 UINT mip_levels = 1);
	~RenderTarget();

	// Management.
	//-----------------------------------------------
	BOOL IsBinded() CONST;

	BOOL Bind();
	VOID Unbind();

	// Getters & Setters.
	//-----------------------------------------------
	Size GetSize() CONST;

	ID3D11RenderTargetView* GetRenderTarget() CONST;
	ID3D11ShaderResourceView* GetResource() CONST;

	// Clearing.
	//-----------------------------------------------
	VOID ClearRenderTarget(CONST Vector4& color);
	VOID ClearRenderTarget(FLOAT r = 0.0f, FLOAT g = 0.0f, FLOAT b = 0.0f, FLOAT a = 1.0f);

protected:
	RenderTarget(CONST RenderTarget&);
	RenderTarget& operator = (CONST RenderTarget&);

private:
	// Attributes.
	//-----------------------------------------------
	// State.
	BOOL							m_binded;
	
	// Descriptions.
	D3D11_TEXTURE2D_DESC			m_tex2d_desc;
	D3D11_RENDER_TARGET_VIEW_DESC   m_rtv_desc;
	D3D11_SHADER_RESOURCE_VIEW_DESC m_srv_desc;

	// Resource.
	ID3D11Texture2D*				m_render_target_texture;

	// Views.
	ID3D11DepthStencilView*			m_depth_stencil_view;
	ID3D11RenderTargetView*			m_render_target_view;
	ID3D11ShaderResourceView*		m_shader_resource_view;
};

